{if condition="$score_info"}
{include file="Public/header" title="编辑成绩"/}
{else/}
{include file="Public/header" title="添加成绩"/}
{/if}
<!-- 主容器 start -->
<div id="container" class="container-fluid">
    <div class="row-fluid">

        <!-- 左侧导航栏 start -->
        {include file="Public/sidebar"/}
        <!-- 左侧导航栏 end -->
        <!-- 主内容 start -->
        <div id="content" class="span10">
            <!-- 标题 start -->
            <div class="pageTit page-header">
                <h1>{if condition="$class_info"}编辑{else/}添加{/if}成绩</h1>
                <div class="opt">
                    <a class="btn btn-info" href="{:U('admin/score/index')}">返回成绩列表</a>
                </div>
            </div>
            <!-- 标题 end -->
            <!-- 内容区块 start -->
            <div class="formBox">
                <form id="addform" action="{:U('admin/score/save')}" method="post" enctype="multipart/form-data">
                    <input name="id" type="hidden" value="{$score_info.Id}" />
                    <div class="control-group">
                        <label>课程选择：</label>
                        {if condition="$score_info"}
                        <p>{:get_title('Lesson',$score_info['lesson_id'])}</p>
                        <input type="hidden" name="lesson_id" value="{$score_info.lesson_id}"/>
                        {else/}
                        <select class="form-control" name="lesson_id" id="select_lesson">
                            <option value='' selected>暂无</option>
                            {$lesson_list = get_list('lesson')}
                            {volist name="lesson_list" id="vo"}
                            <option value="{$vo.Id}" {if condition="$vo['Id'] eq $score_info['lesson_id']"}selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                        {/if}
                        <span class="Validform_checktip"></span>
                    </div>
                    <div class="control-group">
                        <label>学生选择：</label>
                        {if condition="$score_info"}
                        <p>{:get_title('Student',$score_info['std_id'])}</p>
                        <input type="hidden" name="std_id" value="{$score_info.std_id}"/>
                        {else/}
                        <select class="form-control" name="std_id" id="select_lesson">
                            <option value='' selected>暂无</option>
                            {$Student_list = get_list('Student')}
                            {volist name="Student_list" id="vo"}
                            <option value="{$vo.Id}" {if condition="$vo['Id'] eq $score_info['std_id']"}selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                        {/if}
                        <span class="Validform_checktip"></span>
                    </div>
                    <div class="control-group">
                        <label>成绩：</label>
                        <input type="text" name="score" value="{$score_info.score}" />
                        <span class="Validform_checktip"></span>
                    </div>
                    <div style="clear: both"></div>
                    <div class="control-group">
                        <input type="submit" class="btn btn-primary Sub" value="保存" />
                    </div>
                </form>
            </div>
            <!-- 内容区块 end -->
        </div>
        <!-- 主内容 end -->
        <script>
            $(function(){
                //提交表单合法性验证
                $("#addform").Validform({
                    tiptype:function(msg,o,cssctl){
                        if(!o.obj.is("form")){
                            var objtip=o.obj.siblings(".Validform_checktip");
                            cssctl(objtip,o.type);
                            objtip.text(msg);
                        }
                    },
                    label:"label",
                    ajaxPost:true,
                    callback:function(data){
                        if(data.status=="ok"){
                            alert(data.info);
                            window.location.href = "{:U('admin/score/index')}";
                        }else{
                            alert(data.info);
                        }
                    }
                });
            })
        </script>

    </div>
</div>
<!-- 主容器 end -->
{include file="Public/footer"/}